London | 26-ITP-May | Bisrat Tesfay | Sprint 3 | Implement and rewrite#1475
London | 26-ITP-May | Bisrat Tesfay | Sprint 3 | Implement and rewrite#1475B3-Bisrat wants to merge 3 commits into
Conversation
Luro91
left a comment
There was a problem hiding this comment.
Good job.
There is one more error case that you can test in exercise 3.
I noticed that the assertions often have less test cases then the test files. I hope the comments in the test files helped you to think about good values for testing. In general you want to test all the edge case, borders and errors.
| if (angle <= 0 || angle >= 360) { | ||
| return "Invalid angle"; | ||
| } | ||
|
|
||
| if (angle < 90) { | ||
| return "Acute angle"; | ||
| } | ||
|
|
||
| if (angle === 90) { | ||
| return "Right angle"; | ||
| } | ||
|
|
||
| if (angle < 180) { | ||
| return "Obtuse angle"; | ||
| } | ||
|
|
||
| if (angle === 180) { | ||
| return "Straight angle"; | ||
| } | ||
|
|
||
| return "Reflex angle"; |
There was a problem hiding this comment.
Well done on the order of the logic. By putting the invalid values first it is easy to understand which values are valid. THen you go from smallest to biggest angle which makes it easy to follow
| expect(getAngleType(91)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(120)).toEqual("Obtuse angle"); | ||
| expect(getAngleType(179)).toEqual("Obtuse angle"); | ||
| }); | ||
|
|
||
| // Case 4: Straight angle | ||
| test(`should return "Straight angle" when angle is 180`, () => { | ||
| expect(getAngleType(180)).toEqual("Straight angle"); | ||
| }); | ||
|
|
||
| // Case 5: Reflex angles | ||
| test(`should return "Reflex angle" when (180 < angle < 360)`, () => { | ||
| expect(getAngleType(181)).toEqual("Reflex angle"); | ||
| expect(getAngleType(270)).toEqual("Reflex angle"); | ||
| expect(getAngleType(359)).toEqual("Reflex angle"); | ||
| }); | ||
|
|
||
| // Case 6: Invalid angles | ||
| test(`should return "Invalid angle" for invalid angles`, () => { | ||
| expect(getAngleType(0)).toEqual("Invalid angle"); | ||
| expect(getAngleType(-10)).toEqual("Invalid angle"); | ||
| expect(getAngleType(360)).toEqual("Invalid angle"); | ||
| expect(getAngleType(400)).toEqual("Invalid angle"); |
There was a problem hiding this comment.
Well done. Good choices for the boundary cases
| test("should throw an error for invalid cards", () => { | ||
| expect(() => getCardValue("1♠")).toThrow(); | ||
| expect(() => getCardValue("11♣")).toThrow(); | ||
| expect(() => getCardValue("Z♥")).toThrow(); | ||
| expect(() => getCardValue("invalid")).toThrow(); | ||
| }); |
There was a problem hiding this comment.
Can you think of another invalid value? (related to the number rank)
There was a problem hiding this comment.
Good point! I hadn't considered 0 as an invalid number rank. I've added a test for "0♠".
There was a problem hiding this comment.
What if a number is passed without any suit?
Learners, PR Template
Self checklist
Changelist
I have done the implement and rewrite.
Questions